<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">



  
  
    
      
    
    
      
    
  <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
  <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-flash.min.css" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
    
  
  <link href="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet" type="text/css">







  

<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="ts,">





  <link rel="alternate" href="/atom.xml" title="TiX" type="application/atom+xml">






<meta name="description" content="一篇记录ts学习历程的东东。">
<meta name="keywords" content="ts">
<meta property="og:type" content="article">
<meta property="og:title" content="记录ts的学习历程(一)">
<meta property="og:url" content="https://gitee.com/L1334101793/记录ts的学习历程(一)/index.html">
<meta property="og:site_name" content="TiX">
<meta property="og:description" content="一篇记录ts学习历程的东东。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2019-03-04T06:02:34.145Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="记录ts的学习历程(一)">
<meta name="twitter:description" content="一篇记录ts学习历程的东东。">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"right","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://gitee.com/L1334101793/记录ts的学习历程(一)/">





  <title>记录ts的学习历程(一) | TiX</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-right page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">TiX</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">Stay Hungry, Stay Foolish</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://gitee.com/L1334101793/记录ts的学习历程(一)/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="TiX">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="TiX">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">记录ts的学习历程(一)</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-03-04T10:27:33+08:00">
                2019-03-04
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/js/" itemprop="url" rel="index">
                    <span itemprop="name">js</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o">本文阅读</i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>人次
            </span>
          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>一篇记录ts学习历程的东东。<br><a id="more"></a></p>
<h3 id="如何配置vscode自动编译ts文件"><a href="#如何配置vscode自动编译ts文件" class="headerlink" title="如何配置vscode自动编译ts文件"></a>如何配置vscode自动编译ts文件</h3><p>进入项目文件夹，命令行输入。<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tsc --init  <span class="comment">#生成tsconfig.json配置文件</span></span><br></pre></td></tr></table></figure></p>
<p>最后修改tsconfig.json配置文件里的outdir属性输出js到哪里。<br>点击vscode的终端》运行任务》监视tsconfig.json</p>
<h3 id="typeScript中的数据类型"><a href="#typeScript中的数据类型" class="headerlink" title="typeScript中的数据类型"></a>typeScript中的数据类型</h3><p>布尔类型（boolean）,数字类型（number）,字符串类型(string),数组类型（array）,元组类型（tuple）,枚举类型（enum）,<br>任意类型（any）,null 和 undefined,void类型,never类型<br>typescript中为了使编写的代码更规范，更有利于维护，增加了类型校验,写ts代码必须指定类型。</p>
<h4 id="布尔类型（boolean）"><a href="#布尔类型（boolean）" class="headerlink" title="布尔类型（boolean）"></a>布尔类型（boolean）</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">var flag:boolean=<span class="literal">true</span>;</span><br></pre></td></tr></table></figure>
<h4 id="数字类型（number）"><a href="#数字类型（number）" class="headerlink" title="数字类型（number）"></a>数字类型（number）</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">var num:number=123;</span><br></pre></td></tr></table></figure>
<h4 id="字符串类型-string"><a href="#字符串类型-string" class="headerlink" title="字符串类型(string)"></a>字符串类型(string)</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">var str:string=<span class="string">'this is ts'</span>;</span><br></pre></td></tr></table></figure>
<h4 id="数组类型（array）-ts中定义数组有两种方式"><a href="#数组类型（array）-ts中定义数组有两种方式" class="headerlink" title="数组类型（array）  ts中定义数组有两种方式"></a>数组类型（array）  ts中定义数组有两种方式</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">var arr:number[]=[11,22,33];</span><br><span class="line">var arr:Array&lt;number&gt;=[11,22,33];</span><br></pre></td></tr></table></figure>
<h4 id="元组类型（tuple）-属于数组的一种"><a href="#元组类型（tuple）-属于数组的一种" class="headerlink" title="元组类型（tuple）  属于数组的一种"></a>元组类型（tuple）  属于数组的一种</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">let</span> arr:[number,string]=[123,<span class="string">'this is ts'</span>];</span><br></pre></td></tr></table></figure>
<h4 id="枚举类型（enum）"><a href="#枚举类型（enum）" class="headerlink" title="枚举类型（enum）"></a>枚举类型（enum）</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">enum 枚举名&#123; </span><br><span class="line">    标识符[=整型常数], </span><br><span class="line">    标识符[=整型常数], </span><br><span class="line">    ... </span><br><span class="line">    标识符[=整型常数], </span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">enum Err &#123;</span><br><span class="line">  <span class="string">'undefined'</span>=-1,</span><br><span class="line">  <span class="string">'null'</span>=-2,</span><br><span class="line">  <span class="string">'success'</span>=1</span><br><span class="line">  &#125;;</span><br><span class="line">var e:Err=Err.success;</span><br><span class="line">console.log(e);</span><br></pre></td></tr></table></figure>
<h4 id="任意类型（any）及用处"><a href="#任意类型（any）及用处" class="headerlink" title="任意类型（any）及用处"></a>任意类型（any）及用处</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">var oBox:any=document.getElementById(<span class="string">'box'</span>);</span><br><span class="line">oBox.style.color=<span class="string">'red'</span>;</span><br></pre></td></tr></table></figure>
<h4 id="null-和-undefined-其他（never类型）数据类型的子类型-定义没有赋值就是undefined"><a href="#null-和-undefined-其他（never类型）数据类型的子类型-定义没有赋值就是undefined" class="headerlink" title="null 和 undefined 其他（never类型）数据类型的子类型(定义没有赋值就是undefined)"></a>null 和 undefined 其他（never类型）数据类型的子类型(定义没有赋值就是undefined)</h4><h4 id="void类型-typescript中的void表示没有任何类型，一般用于定义方法的时候方法没有返回值。"><a href="#void类型-typescript中的void表示没有任何类型，一般用于定义方法的时候方法没有返回值。" class="headerlink" title="void类型 :typescript中的void表示没有任何类型，一般用于定义方法的时候方法没有返回值。"></a>void类型 :typescript中的void表示没有任何类型，一般用于定义方法的时候方法没有返回值。</h4><p>typescript中的void表示没有任何类型，一般用于定义方法的时候方法没有返回值。</p>
<h4 id="never类型-是其他类型-（包括-null-和-undefined）的子类型，代表从不会出现的值。这意味着声明never的变量只能被never类型所赋值。"><a href="#never类型-是其他类型-（包括-null-和-undefined）的子类型，代表从不会出现的值。这意味着声明never的变量只能被never类型所赋值。" class="headerlink" title="never类型:是其他类型 （包括 null 和 undefined）的子类型，代表从不会出现的值。这意味着声明never的变量只能被never类型所赋值。"></a>never类型:是其他类型 （包括 null 和 undefined）的子类型，代表从不会出现的值。这意味着声明never的变量只能被never类型所赋值。</h4><p>一个元素可能是 number类型 可能是null 可能是undefined<br>var num:number | null | undefined;<br>num=1234;<br>console.log(num)</p>
<h3 id="typeScript中的函数"><a href="#typeScript中的函数" class="headerlink" title="typeScript中的函数"></a>typeScript中的函数</h3><h4 id="函数的定义"><a href="#函数的定义" class="headerlink" title="函数的定义"></a>函数的定义</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">function</span> run():string&#123;</span><br><span class="line">    <span class="built_in">return</span> <span class="string">'run'</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">var fun2=<span class="keyword">function</span>():number&#123;</span><br><span class="line">    <span class="built_in">return</span> 123;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="ts中定义方法传参"><a href="#ts中定义方法传参" class="headerlink" title="ts中定义方法传参"></a>ts中定义方法传参</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">function</span> getInfo(name:string,age:number):string&#123;</span><br><span class="line">    <span class="built_in">return</span> `<span class="variable">$&#123;name&#125;</span> + <span class="variable">$&#123;age&#125;</span>`;</span><br><span class="line">&#125;</span><br><span class="line">alert(getInfo(<span class="string">'zhangsan'</span>,20));</span><br></pre></td></tr></table></figure>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">var getInfo=<span class="keyword">function</span>(name:string,age:number):string&#123;</span><br><span class="line">    <span class="built_in">return</span> `<span class="variable">$&#123;name&#125;</span> + <span class="variable">$&#123;age&#125;</span>`;</span><br><span class="line">&#125;</span><br><span class="line">alert(getInfo(<span class="string">'zhangsan'</span>,40));</span><br></pre></td></tr></table></figure>
<p>没有返回值的方法<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">function</span> run():void&#123;</span><br><span class="line">    console.log(<span class="string">'run'</span>)</span><br><span class="line">&#125;</span><br><span class="line">run();</span><br></pre></td></tr></table></figure></p>
<p>方法可选参数(es5里面方法的实参和行参可以不一样，但是ts中必须一样，如果不一样就需要配置可选参数,可选参数必须配置到参数的最后面)<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">function</span> getInfo(name:string,age?:number):string&#123;</span><br><span class="line">    <span class="keyword">if</span>(age)&#123;</span><br><span class="line">        <span class="built_in">return</span> `<span class="variable">$&#123;name&#125;</span> --- <span class="variable">$&#123;age&#125;</span>`;</span><br><span class="line">    &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">        <span class="built_in">return</span> `<span class="variable">$&#123;name&#125;</span> ---年龄保密`;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>默认参数 可选参数<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">function</span> getInfo(name:string,age:number=20):string&#123;</span><br><span class="line">    <span class="keyword">if</span>(age)&#123;</span><br><span class="line">        <span class="built_in">return</span> `<span class="variable">$&#123;name&#125;</span> --- <span class="variable">$&#123;age&#125;</span>`;</span><br><span class="line">    &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">        <span class="built_in">return</span> `<span class="variable">$&#123;name&#125;</span> ---年龄保密`;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>三点运算符 接受新参传过来的值<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">function</span> sum(...result:number[]):number&#123;</span><br><span class="line">    var sum=0;</span><br><span class="line">    <span class="keyword">for</span>(var i=0;i&lt;result.length;i++)&#123;</span><br><span class="line">        sum+=result[i];  </span><br><span class="line">    &#125;</span><br><span class="line">    <span class="built_in">return</span> sum;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div></div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wcpay.png" alt="TiX 微信支付">
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.png" alt="TiX 支付宝">
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/ts/" rel="tag"># ts</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/如何使用码云和hexo搭建自己的博客/" rel="next" title="如何使用码云和hexo搭建自己的博客">
                <i class="fa fa-chevron-left"></i> 如何使用码云和hexo搭建自己的博客
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/记录ts的学习历程-二/" rel="prev" title="记录ts的学习历程(二)">
                记录ts的学习历程(二) <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">TiX</p>
              <p class="site-description motion-element" itemprop="description">个人学习记录，涉及前端，分享心得等。</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">21</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#如何配置vscode自动编译ts文件"><span class="nav-number">1.</span> <span class="nav-text">如何配置vscode自动编译ts文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#typeScript中的数据类型"><span class="nav-number">2.</span> <span class="nav-text">typeScript中的数据类型</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#布尔类型（boolean）"><span class="nav-number">2.1.</span> <span class="nav-text">布尔类型（boolean）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#数字类型（number）"><span class="nav-number">2.2.</span> <span class="nav-text">数字类型（number）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#字符串类型-string"><span class="nav-number">2.3.</span> <span class="nav-text">字符串类型(string)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#数组类型（array）-ts中定义数组有两种方式"><span class="nav-number">2.4.</span> <span class="nav-text">数组类型（array）  ts中定义数组有两种方式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#元组类型（tuple）-属于数组的一种"><span class="nav-number">2.5.</span> <span class="nav-text">元组类型（tuple）  属于数组的一种</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#枚举类型（enum）"><span class="nav-number">2.6.</span> <span class="nav-text">枚举类型（enum）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#任意类型（any）及用处"><span class="nav-number">2.7.</span> <span class="nav-text">任意类型（any）及用处</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#null-和-undefined-其他（never类型）数据类型的子类型-定义没有赋值就是undefined"><span class="nav-number">2.8.</span> <span class="nav-text">null 和 undefined 其他（never类型）数据类型的子类型(定义没有赋值就是undefined)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#void类型-typescript中的void表示没有任何类型，一般用于定义方法的时候方法没有返回值。"><span class="nav-number">2.9.</span> <span class="nav-text">void类型 :typescript中的void表示没有任何类型，一般用于定义方法的时候方法没有返回值。</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#never类型-是其他类型-（包括-null-和-undefined）的子类型，代表从不会出现的值。这意味着声明never的变量只能被never类型所赋值。"><span class="nav-number">2.10.</span> <span class="nav-text">never类型:是其他类型 （包括 null 和 undefined）的子类型，代表从不会出现的值。这意味着声明never的变量只能被never类型所赋值。</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#typeScript中的函数"><span class="nav-number">3.</span> <span class="nav-text">typeScript中的函数</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#函数的定义"><span class="nav-number">3.1.</span> <span class="nav-text">函数的定义</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#ts中定义方法传参"><span class="nav-number">3.2.</span> <span class="nav-text">ts中定义方法传参</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2019 &mdash; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">TiX</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.4</div>




        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user">访客</i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人次
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye">总访问</i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      人次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery/2.1.3/jquery.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/fastclick/1.0.6/fastclick.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazyload/1.9.3/jquery.lazyload.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.ui.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.pack.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.1/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
